package parser

import (
	"regexp"
	"test_demo/reptile/v1/engine"
)

const menuRegex  = `<a href="(/info-detail-\w+.html)" title="[\s\S]*?"[^>]*>([^<]+)</a>`

func ParseType(contents []byte,_ string) engine.ParseResult {
	rs := engine.ParseResult{}
	reg := regexp.MustCompile(menuRegex)
	match := reg.FindAllSubmatch(contents,-1)
	for _,m := range match {
		rs.Requests = append(rs.Requests,engine.Request{
			Url:   string(m[1]),
			Parse: engine.NewFuncParser(ParseType,"ParseType"),
		})
	}
	return rs
}